#pragma once

#include "Pages/EditorPageModel.h"
#include "EditorMaterialPageModel.m.h"

class RMaterial;
class RMaterialGraphModel;

RCLASS(ExtraHeader= [ "Material/Material.h", "MaterialGraph/MaterialGraphModel.h" ])
class REditorMaterialPageModel : public REditorPageModel
{
    ROBJECT

public:
    virtual TSharedObjectPtr<REditorPageModel> ShareClone(RObject* InOwner) const override;
    virtual bool HasUnsavedData() const override;
    //save the file 
    virtual void LowLevelSave() override;

    virtual SPath GetFilePath() const override
    {
        return FilePath;
    }

    virtual TSharedObjectPtr<RObject> GetFocuseObject() const override;


    static TSharedObjectPtr<REditorMaterialPageModel> Create(
        const SPath&  InFilePath
        , TSharedObjectPtr<RMaterial> InMaterial
        , TSharedObjectPtr<RMaterialGraphModel> InMaterialGraph
        );

    RFIELD()
    SPath FilePath;

    RFIELD()
    TSharedObjectPtr<RMaterial> Material;

    RFIELD()
    TSharedObjectPtr<RMaterialGraphModel> MaterialGraph;

    void UpdateMaterial();
    virtual bool CanUndo() const override;
    virtual bool Undo() override;
    virtual bool CanRedo() const override;
    virtual bool Redo() override;
};